package com.cxs.observer.spring.impl;

import com.cxs.observer.spring.ObServerSpring;
import com.cxs.observer.spring.WeatherSpring;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * @Author: cxs
 */
@Service
public class ClothObServerSpringImpl extends ObServerSpring {
    // 注意循环依赖问题
    @Lazy
    public ClothObServerSpringImpl(WeatherSpring weatherSpring) {
        this.weatherSpring = weatherSpring;
    }

    @Override
    public Object doUpdate() {
        Double temp = this.weatherSpring.getTemp();
        if (temp < 20D) {
            System.out.println("天气变冷 注意增衣物");
        }
        if (temp > 30D) {
            System.out.println("天气炎热 注意防晒");
        }
        return null;
    }
}
